package com.luguangtao.web;

import com.luguangtao.entity.TestUser;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @类名: com.luguangtao.web
 * @作者: lgt
 * @创建时间: 2019-12-13 12:05
 * @描述:
 **/
@RestController
@Api(description = "这是一个测试的接口类,里面有很多的方法",tags = "TestController接口类")
public class TestController {
    @ApiOperation(value = "这个描述方法的作用")  //targs = "这是test01的作用"
    @RequestMapping(value = "test01",method = RequestMethod.POST)
    /*@ApiImplicitParams({
            @ApiImplicitParam(name = "userName",value = "这个参数是一个xxx系统登录用户名",dataType="String",required = true),
            @ApiImplicitParam(name = "password",value = "这个参数是一个xxx系统登录密码",dataType="String",required = true)
    })*/
    @ApiResponses({
            @ApiResponse(code = 200,message = "正常请求通过"),
            @ApiResponse(code = 404,message = "资源不存在")
    })
    public String test01(@ApiParam(name="userName",value="这是用户名",defaultValue = "这是用户名默认值",required = true)String userName,
                         @ApiParam(name="password",value="这是密码",defaultValue = "这是密码默认值",required = true)String password
        ){
        return "测试";
    }


    @ApiOperation(value = "获取用户的信息")  //targs = "这是test01的作用"
    @ApiImplicitParams({
            @ApiImplicitParam(name = "testUser",value = "这是一个实体类",dataType="TestUser",required = true),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "正常请求通过"),
            @ApiResponse(code = 404,message = "资源不存在")
    })
    @RequestMapping(value = "getTestUser",method = RequestMethod.POST)
    public TestUser getTestUser(@RequestBody TestUser testUser){
        return testUser;
    }



    @ApiOperation(value = "获取用户的信息")  //targs = "这是test01的作用"
    @ApiResponses({
            @ApiResponse(code = 200,message = "正常请求通过"),
            @ApiResponse(code = 404,message = "资源不存在")
    })
    @RequestMapping(value = "getTestUser02",method = RequestMethod.POST)
    public TestUser getTestUser02(@ApiParam(name = "testUser",required = true,value="用户实体参数") @RequestBody TestUser testUser){
        return testUser;
    }
}
